<template>
  <el-table
    :height="calTableHeight() - 50"
    show-summary
    :summary-method="handleSum"
    ref="TableRef"
    :data="data">
    <el-table-column type="index" :label="$t('序号')" width="60" align="center" />

    <el-table-column show-overflow-tooltip :label="$t('sku编号')" align="center" prop="skuNo" />

    <el-table-column show-overflow-tooltip :label="$t('sku名字')" align="center" prop="skuName" />

    <el-table-column show-overflow-tooltip :label="$t('申请时价格')" align="center" prop="applyPrice">
      <template #default="{ row }">
        {{ row.applyPrice ? (+row.applyPrice).toFixed() : '' }}
      </template>
    </el-table-column>
    <el-table-column show-overflow-tooltip :label="$t('云价格')" align="center" prop="cloudPrice">
      <template #default="{ row }">
        {{ row.cloudPrice ? (+row.cloudPrice).toFixed() : '' }}
      </template>
    </el-table-column>
    <el-table-column show-overflow-tooltip :label="$t('消费税')" align="center" prop="duty">
      <template #default="{ row }">
        {{ row.duty ? (+row.duty).toFixed() : '' }}
      </template>
    </el-table-column>
    <el-table-column show-overflow-tooltip :label="$t('申请数量')" align="center" prop="applyNum" />
    <el-table-column show-overflow-tooltip :label="$t('卖家支付数量')" align="center" prop="payNum" />
    <el-table-column show-overflow-tooltip :label="$t('收款总数')" align="center" prop="waitPayTotal">
      <template #default="{ row }">
        {{ row.waitPayTotal ? (+row.waitPayTotal).toFixed() : '' }}
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
import handleTableSum from '@/utils/handleSum'

export default {
  activated() {
    this.$nextTick(() => this.$refs['TableRef']?.doLayout())
  },
  props: {
    /**
     * data
     */
    data: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {}
  },
  methods: {
    handleSum(param) {
      /**
       * 需要进行统计的字段
       */
      const data = handleTableSum(param, [])
      console.log(`data ==>`, JSON.parse(JSON.stringify(data)))
      return data
    },

    cancel() {
      this.$emit('update:show', false)
    },
  },
}
</script>
